<template>
	<view class="page-bottom-fixed">
		<form @submit="form_submit" class="form-container">
			<view class="padding-main oh">
				<!-- <view class="form-gorup">
					<view class="br-t padding-top-lg margin-top-xs pr">
						<view class="form-gorup-title">商品名称</view>
						<input type="text" name="tradeName" v-model="product_data.tradeName" maxlength="100"
							placeholder-class="cr-grey" class="cr-base" placeholder="商品名称">
					</view>
				</view> -->
				<!-- <view class="form-gorup">
					<view class="br-t padding-top-lg margin-top-xs pr">
						<view class="form-gorup-title">卖点</view>
						<input type="text" name="storeInfo" v-model="product_data.storeInfo" maxlength="200"
							placeholder-class="cr-grey" class="cr-base" placeholder="卖点最多200个字符">
					</view>
				</view> -->
				<view class="form-gorup">
					<view class="br-t padding-top-lg margin-top-xs pr">
						<view class="form-gorup-title">品类</view>
						<picker name="categoryId" @change="select_category_event" :value="category_value"
							:range="category_list" range-key="cname">
							<view :class="'name ' + ((category_value == null) ? 'cr-grey' : 'cr-base' )">
								{{((category_list[category_value] || null) == null) ? '请选择品类' : category_list[category_value]['cname']}}
							</view>
						</picker>

					</view>
				</view>
				<view class="form-gorup oh">
					<view class="form-gorup-item-left">
						<view class="form-gorup-title">款式<text class="form-group-tips-must">*</text></view>
						<picker name="cateId" @change="select_store_category_event" :value="store_category_value"
							:range="store_category_list" range-key="cateName">
							<view :class="'name ' + ((store_category_value == null) ? 'cr-grey' : 'cr-base' )">
								{{((store_category_list[store_category_value] || null) == null) ? '请选择款式' : store_category_list[store_category_value]['cateName']}}
							</view>
						</picker>
					</view>
					<!-- <view class="form-gorup-item-right">
						<view class="form-gorup-title">品牌系列</view>
						<picker name="brandSeriesId" @change="select_brand_series_event" :value="brand_series_value"
							:range="brand_series_list" range-key="name">
							<view :class="'name ' + ((brand_series_value == null) ? 'cr-grey' : 'cr-base' )">
								{{((brand_series_list[brand_series_value] || null) == null) ? '请选择品牌系列' : brand_series_list[brand_series_value]['name']}}
							</view>
						</picker>
					</view> -->
				</view>
				<view class="idcard-container padding-horizontal-main padding-top-main border-radius-main oh">
					<view class="form-gorup bg-white form-container-upload oh">
						<view class="form-gorup-title">产品图<text class="form-group-tips-must">必传</text></view>
						<view class="form-upload-data">
							<view class="item fl">
								<uni-file-picker v-model="imageValue" :source-type="['album']" file-mediatype="image"
									mode="grid" file-extname="png,jpg" :limit="5" @select="select"
									title="最多上传5张图片,主图使用第一张" />
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="idcard-container padding-horizontal-main padding-top-main border-radius-main oh">
					<view class="form-gorup bg-white form-container-upload oh">
						<view class="form-gorup-title">视频</view>
						<view class="form-upload-data">
							<view class="item fl">
								<uni-file-picker v-model="videoValue" :source-type="['album']" file-mediatype="video"
									mode="list" file-extname="mp4" :limit="1" @select="videoselect" title="请上传MP4文件" />
							</view>
						</view>
					</view>
				</view> -->

				<!-- <view class="form-gorup oh">
					<view class="form-gorup-item-left">
						<view class="form-gorup-title">款号</view>
						<input type="text" name="barCode" v-model="product_data.barCode" maxlength="15"
							placeholder-class="cr-grey" class="cr-base" placeholder="款号">
					</view>
					<view class="form-gorup-item-right">
						<view class="form-gorup-title">排序</view>
						<input type="number" name="sort" v-model="product_data.sort" placeholder-class="cr-grey"
							class="cr-base" placeholder="排序">
					</view>
				</view> -->
				<!-- <view class="form-gorup">
					<view class="br-t padding-top-lg margin-top-xs pr">
						<view class="form-gorup-title">配送方式</view>
						<checkbox-group @change="handleCheckAllChange">
							<label>
								<checkbox value="0" />快递发货
							</label>
						</checkbox-group>
						<checkbox-group @change="handleCheckafhalenAllChange">
							<label>
								<checkbox value="1" />到店自提
							</label>
						</checkbox-group>
					</view>
				</view> -->
				<!-- <view class="form-gorup oh" v-if="show_Postage">
					<view class="form-gorup-item-left" v-if="show_Postage">
						<view class="form-gorup-title">是否包邮<text class="form-group-tips-must">*</text></view>
						<evan-switch v-model="product_data.isPostage" :size="20" @change="changPostage"
							inactive-color="#B8DBF4" active-value="1" inactive-value="0"></evan-switch>
					</view>
					<view class="form-gorup-item-right" v-if="show_is_postage">
						<view class="form-gorup-title">邮费</view>
						<input type="number" name="postage" v-model="product_data.postage" placeholder-class="cr-grey"
							class="cr-base" placeholder="排序">
					</view>
				</view> -->
				<!-- 	<view class="form-gorup oh">
					<view class="form-gorup-item-left">
						<view class="form-gorup-title">精品推荐</view>
						<evan-switch v-model="product_data.isBest" :size="20" inactive-color="#B8DBF4" active-value="1"
							inactive-value="0"></evan-switch>
					</view>
					<view class="form-gorup-item-right">
						<view class="form-gorup-title">优惠推荐</view>
						<evan-switch v-model="product_data.isBenefit" :size="20" inactive-color="#B8DBF4"
							active-value="1" inactive-value="0"></evan-switch>
					</view>
				</view> -->
				<!-- <view class="form-gorup">
					<view class="br-t padding-top-lg margin-top-xs pr">
						<view class="form-gorup-title">品牌系列推荐</view>
						<evan-switch v-model="product_data.isGood" :size="20" inactive-color="#B8DBF4" active-value="1"
							inactive-value="0"></evan-switch>
					</view>
				</view> -->
				<!-- <view class="form-gorup default-checkbox margin-top-xl" @tap="default_ads_change_event">
					<image class="va-m"
						:src="common_static_url+'select' + ((product_data.status || 0) == 1 ? '-active' : '') + '-icon.png'"
						mode="widthFix"></image>
					<text class="va-m margin-left-sm">是否上架</text>
				</view>
				<view class="form-gorup oh">
					<view class="form-gorup-title oh">
						<text>规格</text>
						<view class="padding-right-s va-m fr oh">
							<button type="default" size="mini"
								class="bg-main-pair br-main-pair cr-white text-size-xs pa" @tap="addItem">添加</button>
						</view>
					</view>
				</view> -->
				<!-- <block v-for="(item, index) in dtableData" :key="index">
					<view class="form-gorup oh">
						<view class="form-gorup-title oh">
							<text>操作</text>
							<view class="padding-right-s va-m fr oh">
								<button type="default" size="mini"
									class="bg-main-pair br-main-pair cr-white text-size-xs pa"
									@tap="delItem(index)">删除</button>
							</view>
						</view>
						<view class="form-gorup-item-left">
							<view class="form-gorup-title">金重</view>
							<input type="text" name="goldWeight" v-model="item.goldWeight" maxlength="100"
								placeholder-class="cr-grey" class="cr-base" placeholder="金重">

						</view>
						<view class="form-gorup-item-right">
							<view class="form-gorup-title">尺寸</view>
							<input type="text" v-model="item.measure" maxlength="30" placeholder-class="cr-grey"
								class="cr-base" placeholder="尺寸">
						</view>
						<view class="form-gorup-item-left">
							<view class="form-gorup-title">条码号</view>
							<input type="text" v-model="item.barCode" maxlength="30" placeholder-class="cr-grey"
								class="cr-base" placeholder="条码号">
						</view>
						<view class="form-gorup-item-right">
							<view class="form-gorup-title">库存</view>
							<input type="text" v-model="item.inventory" maxlength="30" placeholder-class="cr-grey"
								class="cr-base" placeholder="库存">
						</view>
						<view class="form-gorup-item-left">
							<view class="form-gorup-title">销售价</view>
							<input type="text" name="salesPrice" v-model="item.salesPrice" maxlength="30"
								placeholder-class="cr-grey" class="cr-base" placeholder="销售价">
						</view>
						<view class="form-gorup-item-right">
							<view class="form-gorup-title">批发价</view>
							<input type="text" name="tradePrice" v-model="item.tradePrice" maxlength="30"
								placeholder-class="cr-grey" class="cr-base" placeholder="批发价">
						</view> -->
				<!-- <view class="form-gorup-item-left">
							<view class="form-gorup-title">市场价</view>
							<input type="text" name="marketPrice"  v-model="item.marketPrice" maxlength="30" placeholder-class="cr-grey" class="cr-base" placeholder="市场价">
						</view>
						<view class="form-gorup-item-right">
							<view class="form-gorup-title">成本价</view>
							<input type="text" name="costPrice" v-model="item.costPrice" maxlength="30" placeholder-class="cr-grey" class="cr-base" placeholder="批发价">
						</view> -->
				<!-- 				</view>
				</block> -->
				<!-- <view class="idcard-container padding-horizontal-main padding-top-main border-radius-main oh">
					<view class="form-gorup bg-white form-container-upload oh">
						<view class="form-gorup-title">详情</view>
						<view class="form-upload-data">
							<view class="item fl">
								<uni-file-picker v-model="descriptionValue" :source-type="['album']"
									file-mediatype="image" mode="grid" file-extname="png,jpg" :limit="10"
									@select="descriptionSelect" title="最多上传10张图片,按顺序排列,如不上传则以产品图为详情内容" />
							</view>
						</view>
					</view>
				</view> -->


				<view class="bottom-fixed padding-main">
					<view class="bottom-line-exclude oh">
						<button class="bg-main br-main cr-white round text-size-sm" type="default" form-type="submit"
							hover-class="none" :disabled="form_submit_disabled_status">保存</button>
					</view>
				</view>

			</view>
		</form>
	</view>
</template>

<script>
	const app = getApp();
	var common_static_url = app.globalData.get_static_url('common');
	import evanSwitch from "../../../components/evan-switch/evan-switch";

	export default {
		data() {
			return {
				//显示包邮情况
				show_Postage: false,
				//不包邮则显示邮费
				show_is_postage: true,
				common_static_url: common_static_url,
				dtableData: null,
				imageValue: [],
				videoValue: [],
				descriptionValue: [],
				product_data: {
					isBest: 0,
					isBenefit: 0,
					isGood: 0,
					status: 1,
					distribution: 0,
					afhalen: 0,
					isPostage: 0,
					postage: 0,
					isGood: 0,
					sort:0
				},
				category_list: [],
				token: '',
				category_id: '',
				category_value: '',
				store_category_list: [],
				store_category_id: '',
				store_category_value: '',
				brand_series_list: [],
				brand_series_id: '',
				brand_series_value: '',
				ditems: [],
				admin_token: "",
				entryTime:0,
			};
		},

		components: {
			evanSwitch
		},
		props: {},
		onLoad(params) {
			this.initItem();
		},
		onShow() {
			// 记录用户进来时间
			this.entryTime = Date.now();
		},
		onUnload() {
			this.OnEntryTime();
		},
		methods: {
			OnEntryTime(){
				var radarlog_data = {
					pageUrl:"pages/manage/note/Notes_stock",
					name:"笔记现货商品上新页",
					remark:"笔记现货商品上新页停留时间",
					entryTime:this.entryTime,
				}
				uni.request({
					url:app.globalData.get_request_url("radarlog/add"),
					data:radarlog_data,
					method:"POST",
					success: (res) => {
						console.log(res,"笔记现货商品上新页停留时间");
					}
				})
			},
			// 获取品类
			get_category_list() {
				uni.request({
					url: app.globalData.data.request_admin_url + 'gold/storeProduct/queryCategoryList/' + app
						.globalData.data.tenantId,
					method: 'GET',
					dataType: 'json',
					header: {
						'Authorization': 'Bearer ' + app.globalData.data.admin_token
					},
					success: res => {
						if (res.data.code == 200) {
							var data = res.data.data;
							this.category_list = data
						} else {
							uni.showToast({
								title: res.data.msg
							})
						}
					},
					fail: () => {
						uni.showToast({
							title: "获取失败"
						})
					}
				});
			},
			get_store_category_list() {
				uni.request({
					url: app.globalData.data.request_admin_url + "gold/storeProduct/quseryCateoryList/" + app
						.globalData.data.tenantId,
					method: 'GET',
					dataType: 'json',
					header: {
						'Authorization': 'Bearer ' + app.globalData.data.admin_token
					},
					success: res => {
						if (res.data.code == 200) {
							var data = res.data.data;
							this.store_category_list = data
						} else {
							uni.showToast({
								title: res.data.msg
							})
						}
					},
					fail: () => {
						uni.showToast({
							title: "获取失败"
						})
					}
				});
			},
			get_brand_series_list() {
				uni.request({
					url: app.globalData.data.request_admin_url + "gold/storeProduct/queryBrandSeriesList/" + app
						.globalData.data.tenantId,
					method: 'GET',
					dataType: 'json',
					header: {
						'Authorization': 'Bearer ' + app.globalData.data.admin_token
					},
					success: res => {
						if (res.data.code == 200) {
							var data = res.data.data;
							this.brand_series_list = data
						} else {
							uni.showToast({
								title: res.data.msg
							})
						}
					},
					fail: () => {
						uni.showToast({
							title: "获取失败"
						})

					}
				});
			},
			// 省份事件
			select_category_event(e) {
				var index = e.detail.value || 0;
				if (index >= 0) {
					var data = this.category_list[index];
					this.category_value = index
					this.category_id = data.categoryId
				}
			},
			// 商品分类事件
			select_store_category_event(e) {
				var index = e.detail.value || 0;
				if (index >= 0) {
					var data = this.store_category_list[index];
					this.store_category_value = index
					this.store_category_id = data.categoryId
				}
			},
			// 商品分类事件
			select_brand_series_event(e) {
				var index = e.detail.value || 0;
				if (index >= 0) {
					var data = this.brand_series_list[index];
					this.brand_series_value = index
					this.brand_series_id = data.brandSeriesId
				}
			},
			handleCheckAllChange(e) {
				var temp_ads = this.product_data;
				let values = e.detail.value;
				if (values.includes("0")) {
					this.show_Postage = true;
					temp_ads['distribution'] = 1;
				} else {
					this.show_Postage = false;
					temp_ads['isPostage'] = 0;
					temp_ads['distribution'] = 0;
				}
				this.product_data = temp_ads

			},
			handleCheckafhalenAllChange(e) {
				var temp_ads = this.product_data;
				let values = e.detail.value;
				if (values.includes("1")) {
					temp_ads['afhalen'] = 1;
				} else {
					temp_ads['afhalen'] = 0;
				}
				this.product_data = temp_ads
			},
			changPostage(val) {
				if (val == 1) {
					this.show_is_postage = false;
					this.product_data['postage'] = 0;
				} else {
					this.show_is_postage = true;
				}
			},
			changisBest(e) {
				var temp_ads = this.product_data;
				let values = e.detail.value;
				if (values.includes("0")) {
					temp_ads['isBest'] = 1;
				} else {
					this.show_is_postage = false;
					temp_ads['isBest'] = 0;
				}
				this.product_data = temp_ads
			},
			changisBenefit(e) {
				var temp_ads = this.product_data;
				let values = e.detail.value;
				if (values.includes("0")) {
					temp_ads['isBenefit'] = 1;
				} else {
					this.show_is_postage = false;
					temp_ads['isBenefit'] = 0;
				}
				this.product_data = temp_ads
			},
			// 是否上架设置改变
			default_ads_change_event(e) {
				var temp_ads = this.product_data;
				temp_ads['status'] = (temp_ads.status || 0) == 1 ? 0 : 1;
				this.product_data = temp_ads
			},
			// select(e) {
			// 	uni.showLoading({
			// 		title: '正在上传图片，请稍候...'
			// 	});
			// 	const tempFilePaths = e.tempFilePaths;
			// 	for (var i = 0; i < tempFilePaths.length; i++) {
			// 		this.uploadFile(tempFilePaths[i], '0')
			// 	}
			// 	//隐藏加载框
			// 	uni.hideLoading();
			// },
			async select(e) {
				uni.showLoading({
					title: '正在上传图片，请稍候...'
				});
				const tempFilePaths = e.tempFilePaths;
				for (var i = 0; i < tempFilePaths.length; i++) {
					await this.uploadFile(tempFilePaths[i], '0');
				}
				//隐藏加载框
				uni.hideLoading();
			},
			descriptionSelect(e) {
				uni.showLoading({
					title: '正在上传图片，请稍候...'
				});
				const tempFilePaths = e.tempFilePaths;
				for (var i = 0; i < tempFilePaths.length; i++) {
					this.uploadFile(tempFilePaths[i], '1')
				}
				//隐藏加载框
				uni.hideLoading();
			},
			videoselect(e) {
				uni.showLoading({
					title: '正在上传视频，请稍候...'
				});
				
				const tempFilePaths = e.tempFilePaths;
				for (var i = 0; i < tempFilePaths.length; i++) {
					this.uploadFile(tempFilePaths[i], '2')
				}
				//隐藏加载框
				uni.hideLoading();
			},
			uploadFile(tempFilePaths, type) {
				return new Promise((resolve, reject) => {
					// 图片上传
					uni.uploadFile({
						url: app.globalData.data.request_admin_url + 'system/oss/upload/',
						filePath: tempFilePaths,
						name: 'file',
						header: {
							'Authorization': 'Bearer ' + app.globalData.data.admin_token
						},
						success: (uploadFileRes) => {
							// 提取图片url
							const res = JSON.parse(uploadFileRes.data);
							if (res.code == 200) {
								if (type == '0') {
									this.imageValue.push({
										name: res.data.fileName,
										url: res.data.url,
										ossId: res.data.ossId
									});
								} else if (type == '1') {
									this.descriptionValue.push({
										name: res.data.fileName,
										url: res.data.url,
										ossId: res.data.ossId
									});
								} else if (type == '2') {
									this.videoValue.push({
										name: res.data.fileName,
										url: res.data.url,
										ossId: res.data.ossId
									});
								}
							} else {
								uni.showToast({
									title: res.msg
								})
							}
							resolve('suc');
						},
						fail: (error) => {
							reject('error')
						}
					});
				})
			},
			// 删除监听
			del(e){
				var num = this.imageValue.findIndex(v => v.ossId === e.tempFile.ossId);
				this.imageValue.splice(num,1);
			},
			// uploadFile(tempFilePaths, type) {
			// 	// 图片上传
			// 	uni.uploadFile({
			// 		url: app.globalData.data.request_admin_url + "system/oss/upload",
			// 		filePath: tempFilePaths,
			// 		name: 'file',
			// 		header: {
			// 			'Authorization': 'Bearer ' + app.globalData.data.admin_token
			// 		},
			// 		success: (uploadFileRes) => {
			// 			console.log(type, "type");
			// 			// 提取图片url
			// 			const res = JSON.parse(uploadFileRes.data);
			// 			console.log(res);

			// 			if (res.code == 200) {

			// 				if (type == 0) {
			// 					console.log(type, "1212");
			// 					this.imageValue.push({
			// 						name: res.data.fileName,
			// 						url: res.data.url,
			// 						ossId: res.data.ossId
			// 					});
			// 				} else if (type == '1') {
			// 					this.descriptionValue.push({
			// 						name: res.data.fileName,
			// 						url: res.data.url,
			// 						ossId: res.data.ossId
			// 					});
			// 				} else if (type == '2') {
			// 					this.videoValue.push({
			// 						name: res.data.fileName,
			// 						url: res.data.url,
			// 						ossId: res.data.ossId
			// 					});
			// 				}
			// 			}
			// 		}
			// 	});
			// },
			// 对象转成指定字符串分隔
			listToString(list, separator) {
				let strs = "";
				separator = separator || ",";
				for (let i in list) {
					if (list[i].ossId) {
						strs += list[i].ossId + separator;
					}
				}
				return strs != "" ? strs.substr(0, strs.length - 1) : "";
			},
			// 对象转成详情内容
			generatedContent(list) {
				let strs = "";
				for (let i in list) {
					if (list[i].url) {
						strs += '<img src="' + list[i].url + '">';
					}
				}
				return strs != "" ? strs : "";
			},
			// 数据提交
			form_submit(e) {
				// 表单数据
				var form_data = e.detail.value;
				// form_data['type'] = '0'; //类型（0黄金商城1钻石商城)
				// form_data['specType'] = '1'; //规格 0单 1多
				// form_data['pricingModel'] = '0'; //计价方式
				// 数据校验
				// var validation = [{
				// 		fields: "tradeName",
				// 		msg: "请填写商品名称"
				// 	},
				// 	// {
				// 	// 	fields: "barCode",
				// 	// 	msg: "请填写款号"
				// 	// },
				// ];

				if (app.globalData.fields_check(form_data)) {
					let list = this.dtableData;
					if (this.imageValue.length == 0) {
						uni.showToast({
							title: "请上传产品图"
						})
						return false;
					}
					form_data['sliderImage'] = this.listToString(this.imageValue, ',');
					// if (this.videoValue.length > 0) {
					// 	form_data['video'] = this.listToString(this.videoValue, ',');
					// }
					if (this.category_id != '') {
						form_data['categoryId'] = this.category_id;
					}
					if (this.store_category_id != '') {
						form_data['cateId'] = this.store_category_id;
					} else {
						uni.showToast({
							title: "请选择款式"
						})

						return false;
					}
					// if (this.brand_series_id != '') {
					// 	form_data['brandSeriesId'] = this.brand_series_id;
					// }
					var detail = [];
					var gwdetail = [];
					let index = 0;
					for (let i in list) {
						this.$set(list[i], 'attrName' + index, '默认');
						var measure = list[i].measure;
						if (measure == undefined || measure.length == 0 || measure == -1 || measure == 0) {

						} else {
							this.$set(list[i], 'attrName' + index, measure);
							this.$set(list[i].detail, list[i].detail.length, {
								'规格': measure
							});
							if (detail.length == 0) {
								detail.push(measure);
							} else {
								if (!detail.includes(measure)) {
									detail.push(measure);
								}
							}
						}
						var temp_value = list[i].goldWeight;
						// if (temp_value == undefined || temp_value.length == 0 || temp_value == -1 || temp_value == 0) {

						// 	uni.showToast({
						// 		title: "请填写金重"
						// 	})
						// 	return false;
						// } else {
						// 	index++;
						// 	this.$set(list[i], 'attrName' + index, temp_value);
						// 	this.$set(list[i].detail, list[i].detail.length, {
						// 		'金重': temp_value
						// 	});
						// 	if (gwdetail.length == 0) {
						// 		gwdetail.push(temp_value);
						// 	} else {
						// 		if (!gwdetail.includes(temp_value)) {
						// 			gwdetail.push(temp_value);
						// 		}

						// 	}

						// }
						temp_value = list[i].salesPrice;
						// if (temp_value == undefined || temp_value.length == 0 || temp_value == -1 || temp_value == 0) {
						// 	uni.showToast({
						// 		title: "请填写销售价"
						// 	})
						// 	return false;
						// }
						temp_value = list[i].tradePrice;
						// if (temp_value == undefined || temp_value.length == 0 || temp_value == -1 || temp_value == 0) {

						// 	uni.showToast({
						// 		title: "请填写批发价"
						// 	})
						// 	return false;
						// }
						temp_value = list[i].inventory;
						// if (temp_value == undefined || temp_value.length == 0 || temp_value == -1 || temp_value == 0) {
						// 	uni.showToast({
						// 		title: "请填写库存"
						// 	})
						// 	return false;
						// }

						temp_value = list[i].marketPrice;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].marketPrice = '0.00';
						}
						temp_value = list[i].costPrice;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].costPrice = '0.00';
						}
						temp_value = list[i].stoneCount;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].stoneCount = '0';
						}
						temp_value = list[i].stoneWeight;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].stoneWeight = '0.00';
						}
						temp_value = list[i].assistantStoneCount;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].assistantStoneCount = '0';
						}
						temp_value = list[i].assistantStoneWeight;
						if (temp_value == undefined || temp_value.length == 0) {
							list[i].assistantStoneWeight = '0.00';
						}
						index = 0;
					}
					// this.dtableData = list;
					// if (detail.length > 0) {
					// 	this.$set(this.ditems, this.ditems.length, {
					// 		attrName: '尺寸',
					// 		detailValue: '',
					// 		detail: detail
					// 	});
					// }
					// if (gwdetail.length > 0) {
					// 	this.$set(this.ditems, this.ditems.length, {
					// 		attrName: '金重',
					// 		detailValue: '',
					// 		detail: gwdetail
					// 	});
					// }
					// const jsonString = JSON.stringify({
					// 	items: this.ditems,
					// 	attrs: this.dtableData
					// });
					// form_data['jsonStr'] = jsonString;
					// form_data['isBest'] = this.product_data['isBest'];
					// form_data['isGood'] = this.product_data['isGood'];
					// form_data['isBenefit'] = this.product_data['isBenefit'];
					form_data['status'] = this.product_data['status'];
					// form_data['distribution'] = this.product_data['distribution'];
					// form_data['afhalen'] = this.product_data['afhalen'];
					form_data['isPostage'] = this.product_data['isPostage'];
					form_data['postage'] = this.product_data['postage'];
					form_data['sort'] = this.product_data['sort'];
					// form_data['isGood'] = this.product_data['isGood'];
					form_data['tenantId'] = app.globalData.data.tenantId;
					// let content = '';
					// if (!typeof this.descriptionValue == '[]') {
					// 	content = this.generatedContent(this.descriptionValue);
					// } else {
					// 	content = this.generatedContent(this.imageValue);
					// }
					// if (content != '') {
					// 	content = '<p>' + content + "</p>";
					// }
					// form_data['description'] = content;
					this.form_submit_disabled_status = true

					uni.showLoading({
						title: '处理中...'
					});
					uni.request({
						url: app.globalData.data.request_admin_url + "mall/storeProductNote",
						method: 'POST',
						data: form_data,
						dataType: 'json',
						header: {
							'Authorization': 'Bearer ' + app.globalData.data.admin_token
						},
						success: res => {
							uni.hideLoading();
							if (res.data.code == 200) {
								uni.showToast({
									title: res.data.msg
								})
								setTimeout(function() {
									uni.navigateBack();
								}, 1000);
							} else {
								this.form_submit_disabled_status = false
								if (app.globalData.is_login_check(res.data)) {
									uni.showToast({
										title: res.data.msg
									})

								} else {
									uni.showToast({
										title: '提交失败，请重试！'
									})
								}
							}
						},
						fail: () => {
							this.form_submit_disabled_status = false
							uni.hideLoading();
							uni.showToast({
								title: '服务器请求出错'
							})

						}
					});
				}
			},
			initItem() {
				var detai = [];
				detai.push({
					'规格': '默认'
				});
				this.ditems.push({
					attrName: '规格',
					detailValue: '',
					detail: ['默认']
				})
				this.dtableData = []
				this.dtableData.push({
					picture: '',
					stoneCount: '',
					stoneWeight: '',
					stoneType: '',
					assistantStoneCount: '',
					assistantStoneWeight: '',
					assistantStoneType: '',
					certificateCode: '',
					salesPrice: '',
					marketPrice: '',
					costPrice: '',
					tradePrice: '',
					inventory: 1,
					barCode: '',
					goldWeight: '',
					measure: '',
					brokerage: '',
					brokerageTwo: '',
					detail: detai,
				});
				this.get_category_list();
				this.get_store_category_list();
				this.get_brand_series_list();
			},
			addItem() {
				var detai = [];
				detai.push({
					'规格': '默认'
				});
				this.dtableData.push({
					picture: '',
					stoneCount: 0,
					stoneWeight: 0.00,
					stoneType: '',
					assistantStoneCount: 0,
					assistantStoneWeight: 0.00,
					assistantStoneType: '',
					salesPrice: 0.00,
					marketPrice: 0.00,
					costPrice: 0.00,
					tradePrice: 0.00,
					inventory: 1,
					barCode: '',
					goldWeight: 0,
					measure: '',
					brokerage: '',
					brokerageTwo: '',
					detail: detai,
				})
			},
			delItem(k) {
				this.dtableData.splice(k, 1);
			}
		}
	};
</script>

<style>
	/**
	 * 页面底部浮动、增加底部边距
	 */
	.page-bottom-fixed {
		padding-bottom: 120rpx !important;
	}

	/**
	 * 表单
	 */
	.form-container .form-gorup {
		padding: 20rpx;
		margin-bottom: 20rpx;
		border-radius: 20rpx;
	}

	.form-container .form-gorup .form-gorup-item-left {
		float: left;
		padding-right: 20rpx;
	}

	.form-container .form-gorup .form-gorup-item-right {
		float: right;
		padding-left: 20rpx;
		border-left: 1px solid #f7f7f7;
	}

	.form-container .form-gorup .form-gorup-item-left,
	.form-container .form-gorup .form-gorup-item-right {
		width: calc(50% - 20rpx - 1px);
	}

	.form-container .form-gorup-submit {
		padding: 20rpx 0;
	}

	.form-container .form-gorup:not(.form-gorup-submit) {
		background: #fff;
	}

	.form-container .form-gorup-title {
		margin-bottom: 5rpx;
		font-weight: 500;
	}

	.form-container .form-group-tips,
	.form-container .form-group-tips-must {
		margin-left: 20rpx;
		font-size: 24rpx;
		color: #ccc;
	}

	.form-container .form-group-tips-must {
		color: #f00;
	}

	.form-container .form-gorup input,
	.form-container .form-gorup textarea,
	.form-container .form-gorup .picker {
		border-radius: 0;
		width: 100%;
		box-sizing: border-box;
		font-size: 28rpx;
	}

	.form-container .form-gorup input,
	.form-container .form-gorup .picker,
	.form-container .form-gorup .radio-gorup {
		height: 70rpx;
		line-height: 70rpx;
	}

	.form-container .form-gorup textarea {
		padding: 0;
		height: 150rpx !important;
		margin-top: 20rpx;
	}

	.form-container .form-gorup-text {
		padding: 20rpx 10rpx;
	}

	.form-container .form-gorup .switch {
		margin: 30rpx 0 20rpx 0;
	}

	.form-container .form-gorup .radio-gorup .radio radio {
		transform: scale(0.7);
	}

	.form-container .form-gorup .radio-gorup .radio:not(:last-child) {
		margin-right: 50rpx;
	}

	/**
	 * 表单图片上传
	 */
	.form-container-upload .form-gorup-title {
		margin-bottom: 20rpx;
	}

	.form-container-upload .form-upload-data .item {
		margin: 10rpx 10rpx 0 0;
		position: relative;
	}

	.form-container-upload .form-upload-data .delete-icon {
		position: absolute;
		top: 0;
		right: 0;
		color: #e5e5e5;
		background-color: #d9534f;
		padding: 5rpx 18rpx;
		font-size: 36rpx;
		border: 1px solid #eee;
		border-radius: 50rpx;
		line-height: 44rpx;
		z-index: 1;
	}

	.form-container-upload .form-upload-data image {
		width: 100%;
		height: 100%;
		padding: 5rpx;
		border: 1px solid #eee;
		display: block;
		border-radius: 10rpx;
	}

	.form-container-upload .upload-icon {
		margin-top: 10rpx;
		width: 160rpx;
		height: 160rpx;
		border: 1px dashed #e9e9e9;
		display: block;
		border-radius: 10rpx;
	}

	/* .padding-main {
	    padding: 20rpx;
	} */

	.br-t {
		border-top: 1px solid #f7f7f7 !important;
	}

	.padding-top-lg {
		padding-top: 20rpx;
	}

	.pr {
		position: relative;
	}

	/**
 * 统一颜色
 * 文本基础色、白色、黑色、灰色、浅灰色、红色、黄色、绿色、蓝色
 */
	.cr-base {
		color: #666 !important;
	}

	.cr-white {
		color: #000 !important;
	}

	.cr-black {
		color: #000 !important;
	}

	.cr-gray {
		color: #888 !important;
	}

	.cr-grey {
		color: #9A9A9A !important;
	}

	.cr-grey-white {
		color: #e7e7e7 !important;
	}

	.cr-red {
		color: #f00 !important;
	}

	.cr-yellow {
		color: #f6c133 !important;
	}

	.cr-green {
		color: #1AAD19 !important;
	}

	.cr-blue {
		color: #2196F3 !important;
	}

	.cr-b5 {
		color: #b59364 !important;
	}

	.bg-white {
		background-color: #fff !important;
	}

	.oh {
		overflow: hidden;
	}

	.va-m {
		vertical-align: middle;
	}

	.margin-top-xl {
		margin-top: 25rpx;
	}

	.margin-top-xs {
		margin-top: 5rpx;
	}

	.margin-left-sm {
		margin-left: 10rpx;
	}

	.padding-right-s {
		padding-right: 130rpx;
	}

	.default-checkbox image {
		width: 35rpx;
		height: 35rpx !important;
	}
</style>